const express = require("express")
const session = require("express-session")
const ejs = require("ejs")
const infoModel = require("./database/model/info")
const noteModel = require("./database/model/note")
const loginVerify = require("./middleware/verify")
const pageRouter = require("./routers/pageRouter")
const loginRouter = require("./routers/loginRouter")
const noteRouter = require("./routers/nodeRouter")
const app = express()
app.set("views",__dirname+"/html")   // 设置ejs模板所在目录
app.engine("html",ejs.renderFile)   // 调用ejs.engine方法，设置ejs渲染模板文件后缀类型
app.use(express.urlencoded({extended:false}))   // 使用获取请求体数据中间件
const data = require("./database/user.json")
const { use } = require("./routers/loginRouter")

// 使用session中间件并配置
app.use(session({
    name: "id",
    secret: "sss",
    saveUninitialized: false,
    resave: false,
    cookie: {
        httpOnly: true,
        maxAge: 1000*60*60
    }
}))

app.use(pageRouter)
app.use(loginRouter)
app.use(noteRouter)

app.listen(80,()=>{
    console.log("成功");
})